home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Tool Chest / Dev.CD Feb 97 TC.toast / Sample Code / QuickTime / JPEG Sample / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-22  |  3.3 KB  |  149 lines  |  [TEXT/MPCC]

  1. /*************************************************************************************
  2. #
  3. #        main.c
  4. #
  5. #        This is the main entry point.
  6. #
  7. #        Author(s):     Michael Marinkovich & Guillermo Ortiz
  8. #                    Apple Developer Technical Support
  9. #                    marink@apple.com
  10. #
  11. #        Modification History: 
  12. #
  13. #            4/3/96        MWM     Initial coding                     
  14. #
  15. #        Copyright © 1992-96 Apple Computer, Inc., All Rights Reserved
  16. #
  17. #
  18. #        You may incorporate this sample code into your applications without
  19. #        restriction, though the sample code has been provided "AS IS" and the
  20. #        responsibility for its operation is 100% yours.  However, what you are
  21. #        not permitted to do is to redistribute the source as "DSC Sample Code"
  22. #        after having made changes. If you're going to re-distribute the source,
  23. #        we require that you make it clear in the source that the code was
  24. #        descended from Apple Sample Code, but that you've made changes.
  25. #
  26. *************************************************************************************/
  27.  
  28. #include <ToolUtils.h>
  29.  
  30. #include "App.h"
  31. #include "Global.h"
  32. #include "Proto.h"
  33.  
  34.  
  35.  
  36. //----------------------------------------------------------------------
  37. //
  38. //    main - main entry point of our program
  39. //
  40. //
  41. //----------------------------------------------------------------------
  42.  
  43. void main(void)
  44. {
  45.     OSErr            err;
  46.     long            total, contig;
  47.     short            m = 5;
  48.         
  49.     MaxApplZone();
  50.     
  51.     for (;m == 0;m--)                 // alloc the master pointers
  52.     {
  53.         MoreMasters();
  54.     }
  55.     
  56.     err = Initialize();
  57.     
  58.     EventLoop();
  59.         
  60.     (void) RemoveDMNotification();
  61.  
  62.     ExitToShell();
  63.  
  64. }
  65.  
  66.  
  67. //----------------------------------------------------------------------
  68. //
  69. //    HandleError - basic error notification procedure
  70. //
  71. //
  72. //----------------------------------------------------------------------
  73.  
  74. void HandleError(short errNo,Boolean fatal)
  75. {
  76.     DialogPtr            errDialog;
  77.     short                itemHit;
  78.     short                c;
  79.     Handle                button;
  80.     short                itemType;
  81.     Rect                itemRect;
  82.     StringHandle        errString;
  83.     Str255                numString;
  84.     GrafPtr                oldPort;
  85.     
  86.     GetPort(&oldPort);
  87.     SysBeep(30);
  88.     SetCursor(&qd.arrow);
  89.     
  90.     errDialog = GetNewDialog(rErrorDlg, nil, (WindowPtr) -1);
  91.     if (errDialog != nil) {
  92.         ShowWindow(errDialog);
  93.         SetPort(errDialog);
  94.         
  95.         PenPat(&qd.gray);                                // frame user areas
  96.         for (c = 7;c < 9;c++) {
  97.             GetDItem(errDialog,c,&itemType,&button,&itemRect);
  98.             FrameRect(&itemRect);
  99.         }
  100.         PenPat(normal);
  101.  
  102.         GetDItem( errDialog, fatal ? 2 : 1, &itemType, &button, &itemRect );
  103.         HiliteControl( (ControlHandle)button, 255);         //    unhilite appropriate button
  104.         
  105.         SetDialogDefaultItem(errDialog,fatal  ? 1 : 2);
  106.         
  107.         NumToString( errNo, numString );
  108.         if ( errNo < 0 )
  109.             errNo = -errNo + 200;
  110.         errString = GetString( 128 + errNo );
  111.         if ( errString == nil )
  112.                 errString = GetString( 128 );
  113.         HLock((Handle)errString);
  114.         
  115.         ParamText( numString, *errString, nil, nil );
  116.     
  117.         HUnlock((Handle)errString);
  118.         
  119.         ModalDialog( nil, &itemHit );
  120.         
  121.         SetPort( oldPort );
  122.  
  123.         DisposeWindow( errDialog );
  124.     }
  125.     else
  126.         ExitToShell();        // since didn't have mem to open dialog assume the worst
  127.             
  128.     if (fatal) 
  129.         ExitToShell();        //    it's a bad one, get out of here
  130.     
  131. }
  132.  
  133.  
  134. //----------------------------------------------------------------------
  135. //
  136. //    HandleAlert - display alert and then exit to shell
  137. //
  138. //
  139. //----------------------------------------------------------------------
  140.  
  141. void HandleAlert(short alertID)
  142. {
  143.     short            item;
  144.     
  145.     
  146.     item = Alert(alertID,nil);
  147.     ExitToShell();
  148.  
  149. }